home *** CD-ROM | disk | FTP | other *** search
- Path: newsbf02.news.aol.com!not-for-mail
- From: shinjinrui@aol.com (ShinJinRui)
- Newsgroups: comp.lang.c
- Subject: Forward Struct Reference
- Date: 21 Mar 1996 01:47:21 -0500
- Organization: America Online, Inc. (1-800-827-6364)
- Sender: root@newsbf02.news.aol.com
- Message-ID: <4iqu1p$edq@newsbf02.news.aol.com>
- Reply-To: shinjinrui@aol.com (ShinJinRui)
-
- What is the best way to declare a typdef for both a struct and a contained
- function that operates on it? I want to have a structure that contains a
- pointer to a function that operates on the structure.
-
- example:
- /*
- * declare typedef to a function "FuncType" which operates on a
- pointer
- * to a struct of type "structType" (typedef of structType follows
- below).
- */
- typedef void FuncType(*structType);
-
- /*
- * Declare the structure's type
- */
- typedef struct structType_tag {
- int a;
- int b;
- void (*FuncType)(*structType);
- } structType;
-
-
- This confuses the compiler, because "structType" is not defined (yet)
- where the "funcType" typedef is declared.
-
- Any comments or suggestions?
-